<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

  <link rel="stylesheet" href="../plugins/elementui/index.css">

  <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">

  <link rel="stylesheet" href="../css/style.css">
  <style>
    html {
      height: 100%;
      width: 100%;
      overflow: hidden;
      margin: 0;
      padding: 0;
      /*background: url("../image/img.png") no-repeat 0px 0px;*/
      background-size: 100% 100%;
      -moz-background-size: 100% 100%;
    }
  </style>
</head>
<style scoped>

  .login-box {
    border: 1px solid #DCDFE6;
    width: 350px;
    margin: 180px auto;
    padding: 35px 35px 15px 35px;
    border-radius: 5px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    box-shadow: 0 0 25px #909399;
  }

  .login-title {
    text-align: center;
    margin: 0 auto 40px auto;
    color: #303133;
  }
</style>
<body>

<div id="app">
  <el-form ref="loginForm" :model="form"  label-width="80px" class="login-box">
    <h3 class="login-title">登录</h3>

      <el-row>

        <el-col :span="24">

          <el-form-item label="账号">

            <el-input v-model="form.username" type="text" placeholder="请输入账号"></el-input>

          </el-form-item>

        </el-col>

      </el-row>

    <el-row>

      <el-col :span="24">

        <el-form-item label="密码">

          <el-input v-model="form.password" type="password" placeholder="请输入密码"></el-input>

        </el-form-item>

      </el-col>

    </el-row>

    <el-form-item>
      <el-radio v-model="radio" label="1">管理员</el-radio>
      <el-radio v-model="radio" label="2">操作员</el-radio>
    </el-form-item>


    <el-form-item>
      <el-button type="" @click="onSubmit()">登录</el-button>
    </el-form-item>
  </el-form>

</div>

</body>

<script src="../js/vue.js"></script>

<script src="../plugins/elementui/index.js"></script>

<script type="text/javascript" src="../js/jquery.min.js"></script>

<script src="../js/axios-0.18.0.js"></script>


<script>
  var vue=new Vue({
    el:'#app',
    data() {
      return {
        form: {
          username: '',
          password: ''
        },
        radio:'1'
      }
    },
    methods: {
      onSubmit(){
        const op = {"name" : this.form.username, "identity" : this.form.password};
        if (this.radio == '1') {
          console.log(op)
          axios.post("http://localhost:8080/manages/login", this.form).then((res) => {
            console.log(res.data);
            if (res.data.code == 20011) {
              this.$message.success("登入成功");
              window.location.href = "manage.html"
            } else if (res.data.code == 40010) {
              this.$message.error("登入失败,账号或密码错误");
            }
          });
        }else{
          console.log(op)
          axios.post("http://localhost:8080/operators/login",op).then((res)=>{
            console.log(res.data);
            if(res.data.code == 20011){
              window.location.href="http://localhost:8080/pages/Account.html?id="+res.data.data
            }else if(res.data.code ==40010){
              this.$message.error("登入失败,账号或密码错误");
            }
          });
        }
      }
    }
  })
</script>


</html>